# Maintainer: Biswapriyo Nath <nathbappai@gmail.com>

_realname=libqalculate
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=5.5.2
pkgrel=2
pkgdesc="Multi-purpose desktop calculator (mingw-w64)"
arch=('any')
mingw_arch=('ucrt64' 'clang64' 'clangarm64')
url='https://qalculate.github.io/'
msys2_repository_url='https://github.com/Qalculate/libqalculate'
license=('spdx:GPL-2.0-or-later')
depends=(
  "${MINGW_PACKAGE_PREFIX}-curl"
  "${MINGW_PACKAGE_PREFIX}-gettext-runtime"
  "${MINGW_PACKAGE_PREFIX}-gmp"
  "${MINGW_PACKAGE_PREFIX}-icu"
  "${MINGW_PACKAGE_PREFIX}-libiconv"
  "${MINGW_PACKAGE_PREFIX}-libwinpthread"
  "${MINGW_PACKAGE_PREFIX}-libxml2"
  "${MINGW_PACKAGE_PREFIX}-mpfr"
  "${MINGW_PACKAGE_PREFIX}-readline"
)
makedepends=(
  "${MINGW_PACKAGE_PREFIX}-cc"
  "${MINGW_PACKAGE_PREFIX}-autotools"
  "${MINGW_PACKAGE_PREFIX}-gettext-tools"
  "intltool"
)
source=("https://github.com/Qalculate/libqalculate/releases/download/v${pkgver}/${_realname}-${pkgver}.tar.gz")
sha256sums=('fc14d4527dccfc9189684b9fcd64d78aa67ae5383012c66e1596b2531f5daef1')

prepare() {
  cd "${_realname}-${pkgver}"

  # for clang
  autoreconf -fiv
}

build() {
  mkdir -p "build-${MSYSTEM}" && cd "build-${MSYSTEM}"

  ../"${_realname}-${pkgver}"/configure \
    --prefix="${MINGW_PREFIX}" \
    --enable-static \
    --enable-shared

  make
}

package() {
  cd "${srcdir}/build-${MSYSTEM}"
  make install DESTDIR="${pkgdir}"
  install -Dm644 "${srcdir}/${_realname}-${pkgver}/COPYING" "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/COPYING"
}
